package com.cyj.springbootservice.controller.mybatisplus;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cyj.springbootservice.api.entity.Aerial;
import com.cyj.springbootservice.api.vo.AerialVO;
import com.cyj.springbootservice.service.IAerialLatitudeAndLongitudeService;
import com.cyj.springbootservice.service.IAerialService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @Author C_Y_J
 * @create 2021/10/7 13:51
 **/
@RestController
@AllArgsConstructor
@RequestMapping(value = "/aerial")
public class AerialController {

    private IAerialService aerialService;

    private IAerialLatitudeAndLongitudeService aerialLatitudeAndLongitudeService;

    /**
     * 一对多分页查询
     *
     * @return
     */
    @PostMapping("/save")
    public Boolean save() {
        return aerialService.sumbit();
    }


    /**
     * 一对多分页查询
     *
     * @return
     */
    @PostMapping("/list")
    public IPage<AerialVO> list(@RequestBody Aerial aerial, Integer current, Integer size) {
        IPage<AerialVO> IPage = new Page<>(current, size);
        return aerialService.findByPage(IPage, aerial);
    }

    /**
     * 一对多分页查询
     *
     * @return
     */
    @PostMapping("/page")
    public IPage<AerialVO> page(@RequestBody Aerial aerial, Integer current, Integer size) {
        IPage<AerialVO> IPage = new Page<>(current, size);
        return aerialService.findByPage2(IPage, aerial);
    }
}
